package com.xyoto.community.adminController;

import com.xyoto.community.dto.DeleteProverbDTO;
import com.xyoto.community.dto.ProverbDTO;
import com.xyoto.community.service.ProverbService;
import com.xyoto.community.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * Author: 廖振辉
 * Date: 2021/11/17
 * Description: 金句后台接口
 */
@Api(tags = "每日金句（后台）")
@RestController
@RequestMapping("/proverb/admin")
public class ProverbAdminController {

    @Autowired
    private ProverbService proverbService;

    /**
     * 新增每日金句
     * @author 廖振辉
     * @param proverbDTO
     * @return {@link Result}
     */
    @ApiOperation("新增每日金句")
    @PostMapping("/add")
    public Result addOne(@Valid @RequestBody ProverbDTO proverbDTO){
        return proverbService.addOne(proverbDTO);
    }

    /**
     * 删除每日金句
     * @author 廖振辉
     * @param deleteProverbDTO
     * @return {@link Result}
     */
    @ApiOperation("删除每日金句")
    @DeleteMapping("/delete")
    public Result deleteById(@Valid @RequestBody DeleteProverbDTO deleteProverbDTO){
        return proverbService.deleteById(deleteProverbDTO);
    }

}
